package fauxman.InkyStates;

import java.awt.Point;

import fauxman.DynamicElements.BlinkyGhost;
import fauxman.DynamicElements.FauxMan;
import fauxman.DynamicElements.Ghost;
import fauxman.model.WorldModel;
import fauxman.utilities.ActionUtil;
import fauxman.utilities.SpriteUtil;

public class ChaseInkyState extends InkyState {
	private static ChaseInkyState instance;
	
	private ChaseInkyState(){
	}
	
	public static ChaseInkyState getInstance(){
		if (instance==null)
			instance = new ChaseInkyState();
		return instance;
	}
	
	public void setAppearance(int appearanceID, Ghost g) {
		g.setAppearance(SpriteUtil.getInkySprite(appearanceID));
	}

	@Override
	public int[] getTarget(WorldModel model, Ghost g) {
		BlinkyGhost bg = model.getBlinky();
		FauxMan fm = model.getFauxman();
		Point bgPos = bg.getDiscretePosition();
		Point fmTargetPoint = ActionUtil.getNextPosition(fm.getDiscretePosition(), 2, fm.getCurrentDirection()); //Inky looks 2 units ahead of PMan's position
		int[] target = new int[2];
		target[0] = (fmTargetPoint.x - bgPos.x)*2 + bgPos.x;
		target[1] = (fmTargetPoint.y - bgPos.y)*2 + bgPos.y;
//		System.out.println("blinky: "+bgPos.x+", y: "+bgPos.y);
//		System.out.println("pacManTarget x: "+ fmTargetPoint.x +", y: "+fmTargetPoint.y);
//		System.out.println("target x: "+target[0]+", y: "+target[1]);

		// TODO Auto-generated method stub
		return target;
	}
}
